package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfUserMobileConnection;
import com.ruoyi.yf.service.IYfUserMobileConnectionService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户 手机终端关联Controller
 * 
 * @author XiaoYi...
 * @date 2020-03-17
 * cdb0b5f4-252f-4bda-a271-2b9512717d0c
 */
@Controller
@RequestMapping("/yf/connection")
public class YfUserMobileConnectionController extends BaseController
{
    private String prefix = "yf/connection";

    @Autowired
    private IYfUserMobileConnectionService yfUserMobileConnectionService;

    @RequiresPermissions("yf:connection:view")
    @GetMapping()
    public String connection()
    {
        return prefix + "/connection";
    }

    /**
     * 查询用户 手机终端关联列表
     * 4b415909-4d10-456a-996a-a37041244ea3
     */
    @RequiresPermissions("yf:connection:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfUserMobileConnection yfUserMobileConnection)
    {
        startPage();
        List<YfUserMobileConnection> list = yfUserMobileConnectionService.selectYfUserMobileConnectionList(yfUserMobileConnection);
        return getDataTable(list);
    }

    /**
     * 导出用户 手机终端关联列表
     * ead1028e-082b-4f82-a547-a6f7f1b75e29
     */
    @RequiresPermissions("yf:connection:export")
    @Log(title = "用户 手机终端关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfUserMobileConnection yfUserMobileConnection)
    {
        List<YfUserMobileConnection> list = yfUserMobileConnectionService.selectYfUserMobileConnectionList(yfUserMobileConnection);
        ExcelUtil<YfUserMobileConnection> util = new ExcelUtil<YfUserMobileConnection>(YfUserMobileConnection.class);
        return util.exportExcel(list, "connection");
    }

    /**
     * 新增用户 手机终端关联
     * 013a67ca-8970-4a96-ac12-23f41ef2115d
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户 手机终端关联
     * 7ae4ced0-d1c2-4118-9845-ec275fe6a8e7
     */
    @RequiresPermissions("yf:connection:add")
    @Log(title = "用户 手机终端关联", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfUserMobileConnection yfUserMobileConnection)
    {
        return toAjax(yfUserMobileConnectionService.insertYfUserMobileConnection(yfUserMobileConnection));
    }

    /**
     * 修改用户 手机终端关联
     * e208ab25-4713-4144-9958-f16f138fe90c
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        YfUserMobileConnection yfUserMobileConnection = yfUserMobileConnectionService.selectYfUserMobileConnectionById(id);
        mmap.put("yfUserMobileConnection", yfUserMobileConnection);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户 手机终端关联
     * deadb2ed-03b2-482f-a1eb-32824ce615f7
     */
    @RequiresPermissions("yf:connection:edit")
    @Log(title = "用户 手机终端关联", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfUserMobileConnection yfUserMobileConnection)
    {
        return toAjax(yfUserMobileConnectionService.updateYfUserMobileConnection(yfUserMobileConnection));
    }

    /**
     * 删除用户 手机终端关联
     * 296afe99-ddc6-41ef-90fb-5db89a12de1a
     */
    @RequiresPermissions("yf:connection:remove")
    @Log(title = "用户 手机终端关联", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfUserMobileConnectionService.deleteYfUserMobileConnectionByIds(ids));
    }
}
